﻿// Decompiled with JetBrains decompiler
// Type: System.Web.Razor.Generator.RazorDirectiveAttributeCodeGenerator
// Assembly: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// MVID: 682513D6-F37E-48AC-9909-F3EE103CFF14
// Assembly location: D:\Project\Idea\无人机外网\uav\客户端工程\排查工具\bin\Release\System.Web.Razor.dll

using Microsoft.Internal.Web.Utils;
using System.CodeDom;
using System.Web.Razor.Parser.SyntaxTree;

namespace System.Web.Razor.Generator
{
  /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code. Represents a code generator for Razor directive attribute. </summary>
  public class RazorDirectiveAttributeCodeGenerator : SpanCodeGenerator
  {
    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code. Initializes a new instance of the <see cref="T:System.Web.Razor.Generator.RazorDirectiveAttributeCodeGenerator" /> class.</summary>
    /// <param name="name">The name of the directive attribute.</param>
    /// <param name="value">The value of the directive attribute.</param>
    public RazorDirectiveAttributeCodeGenerator(string name, string value)
    {
      this.Name = !string.IsNullOrEmpty(name) ? name : throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, nameof (name));
      this.Value = value ?? string.Empty;
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code. Gets or sets the name of the directive attribute.</summary>
    /// <returns>The name of the directive attribute.</returns>
    public string Name { get; private set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code. Gets or sets the value of the directive attribute.</summary>
    /// <returns>The value of the directive attribute.</returns>
    public string Value { get; private set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code. Generates the code for the directive attribute.</summary>
    /// <param name="target">The source span whose content represents the directive attribute to generate.</param>
    /// <param name="context">The context of the code generator.</param>
    public override void GenerateCode(Span target, CodeGeneratorContext context)
    {
      CodeAttributeDeclaration attributeDeclaration = new CodeAttributeDeclaration(new CodeTypeReference(typeof (RazorDirectiveAttribute)), new CodeAttributeArgument[2]
      {
        new CodeAttributeArgument((CodeExpression) new CodePrimitiveExpression((object) this.Name)),
        new CodeAttributeArgument((CodeExpression) new CodePrimitiveExpression((object) this.Value))
      });
      context.GeneratedClass.CustomAttributes.Add(attributeDeclaration);
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code. Returns the string representation for this instance.</summary>
    /// <returns>The string representation for this instance.</returns>
    public override string ToString() => "Directive: " + this.Name + ", Value: " + this.Value;

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code. Determines whether the specified object is equal to this instance.</summary>
    /// <returns>true if the specified object is equal to this instance; otherwise, false.</returns>
    /// <param name="obj">The object to compare to this instance.</param>
    public override bool Equals(object obj) => obj is RazorDirectiveAttributeCodeGenerator attributeCodeGenerator && this.Name.Equals(attributeCodeGenerator.Name, StringComparison.OrdinalIgnoreCase) && this.Value.Equals(attributeCodeGenerator.Value, StringComparison.OrdinalIgnoreCase);

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code. Returns the hash code for this instance.</summary>
    /// <returns>The hash code for this instance.</returns>
    public override int GetHashCode() => Tuple.Create<string, string>(this.Name.ToUpperInvariant(), this.Value.ToUpperInvariant()).GetHashCode();
  }
}
